package test.freelinz.smart.gwtex.freelinz.client;



import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.KeyboardListener;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;

import freelinz.smart.gwtex.client.ui.FirstPanel;
import freelinz.smart.gwtex.client.ui.SmartKit;
import freelinz.smart.gwtex.client.ui.SmartKitsV;
import freelinz.smart.gwtex.client.ui.SpliterV;
import freelinz.smart.gwtex.client.ui.SmartKit.ResizedWidget;
import freelinz.smart.gwtex.client.ui.SmartKitsAll.Resized;
import freelinz.smart.gwtex.client.ui.SmartKitsAll.SpliterI.SpliterType;
//<meta http-equiv='Content-Type' content='application/xhtml+xml; charset=utf-8'></meta>
/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class freelinz implements EntryPoint {
	public void onModuleLoad() {
		RootPanel rootPanel = RootPanel.get();
		SmartKit one = new SmartKit();
        TextBox t = new TextBox();
        ListBox listBox = new ListBox();
//        listBox.setVisibleItemCount(100);
        Button b = new Button();
        
        Resized tone = new ResizedWidget(listBox);
        one.addResizedWidget(tone);
        one.addResizedListener(tone);
        
        SmartKit two = new SmartKit();
        Resized ttwo = new ResizedWidget(t);
        two.addResizedWidget(ttwo);
        two.addResizedListener(ttwo);
        
        SmartKit three = new SmartKit();
        Resized tthree = new ResizedWidget(b);
        three.addResizedWidget(tthree);
        three.addResizedListener(tthree);
        
        SpliterV spliter = new SpliterV();
        spliter.setVH(SpliterType.V);
        
        SmartKitsV skits = new SmartKitsV();
        skits.addSmartKit(one, two, spliter);
        
        SpliterV spliter2 = new SpliterV();
        spliter2.setVH(SpliterType.V);

        skits.addSmartKit(two, three, spliter2);

        FirstPanel firstPanel = new FirstPanel(skits);
        rootPanel.add(firstPanel);
//        rootPanel.add(t);
        listBox.addKeyboardListener(new KeyboardListener(){

            public void onKeyDown(Widget sender, char keyCode, int modifiers)
            {
                if(keyCode == '1')
                {
                    DOM.setStyleAttribute(sender.getElement(), "height", (sender.getOffsetHeight()-1)+"px");
                }
                if(keyCode == '2')
                {
                    DOM.setStyleAttribute(sender.getElement(), "height", (sender.getOffsetHeight()+1)+"px");
                }
                
            }

            public void onKeyPress(Widget sender, char keyCode, int modifiers)
            {
                // TODO Auto-generated method stub
                
            }

            public void onKeyUp(Widget sender, char keyCode, int modifiers)
            {
                // TODO Auto-generated method stub
                
            }
            
        });
        
        t.addKeyboardListener(new KeyboardListener(){

            public void onKeyDown(Widget sender, char keyCode, int modifiers)
            {
                if(keyCode == '1')
                {
                    DOM.setStyleAttribute(sender.getElement(), "height", (sender.getOffsetHeight()-1)+"px");
                }
                if(keyCode == '2')
                {
                    DOM.setStyleAttribute(sender.getElement(), "height", (sender.getOffsetHeight()+1)+"px");
                }
                
            }

            public void onKeyPress(Widget sender, char keyCode, int modifiers)
            {
                // TODO Auto-generated method stub
                
            }

            public void onKeyUp(Widget sender, char keyCode, int modifiers)
            {
                // TODO Auto-generated method stub
                
            }
            
        });
//        rootPanel.add(t);
//        Button b = new Button("addH");
//        rootPanel.add(b);
//        b.addClickListener(new ClickListener(){
//
//            public void onClick(Widget sender)
//            {
//                String h = t.getText();
//                t.setHeight(h+"px");  
//            }
//            
//        });
//        Button bw = new Button("addw");
//        rootPanel.add(bw);
//        bw.addClickListener(new ClickListener(){
//
//            public void onClick(Widget sender)
//            {
//                String w = t.getText();
//                t.setWidth(w+"px");
//            }
//            
//        });
	}
}
